package com.zl.zsk.config.security;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.zl.zsk.constant.RetCode;
import com.zl.zsk.pojo.vo.Result;
import com.zl.zsk.util.SecurityResponse;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.web.access.AccessDeniedHandler;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @author lxb
 * @version 1.0.0
 * @desc:
 * @date 2020-03-13 17:45
 */
public class HandleAccessDeny implements AccessDeniedHandler {
    @Override
    public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException e) throws IOException, ServletException {
        Result result = new Result(null,e.getMessage(),false,RetCode.AUTH_DENY.code);
        SecurityResponse.getCommonResponse(response,result);
    }
}
